/* ==================
         开关
 ==================== */
@import "./var.scss";

.diygw-checkbox,.diygw-radio {
  -webkit-appearance: none;
  width: 0;
  height: 0;
  display: none;
  border: none;
  float: left;
}
.diygw-checkbox-label,.diygw-radio-label {
  display: flex;
  max-width: 100%;
  margin-bottom: 5px;
  margin-right: 5px;
  align-items: center;
}

.diygw-icon-radio {
  border-radius: 100%;
  width: 18px;
  height: 18px;
  margin-right: 5px;
  border: 1px solid #b8b8b8;
  vertical-align: top;
}

.diygw-icon-radio.checked {
  background-image: url();
  background-size: 100%;
  border-radius: 100%;
  background-color: #04be02;
  border: 1px solid #04be02;
}


.diygw-icon-checkbox {
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border: 1px solid #b8b8b8;
  margin-right: 5px;
  vertical-align: top;
}

.diygw-icon-checkbox.checked {
  background-image: url();
  background-size: 100%;
  background-color: #04be02;
  border: 1px solid #04be02;
}

.diygw-switch-box {
  position: relative;
  width: 42px;
  height: 22px;
  border: 1px solid #DFDFDF;
  outline: 0;
  border-radius: 16px;
  box-sizing: border-box;
  background-color: #DFDFDF;
  transition: background-color 0.1s,border 0.1s;
}
.diygw-switch-box:before {
  content: " ";
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 20px;
  border-radius: 15px;
  background-color: #FDFDFD;
  transition: transform 0.35s cubic-bezier(0.45,1,0.4,1);
}

.diygw-switch-box:after {
  content: " ";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 15px;
  background-color: #FFFFFF;
  box-shadow: 0 1rpx 6rpx rgba(0,0,0,0.4);
  transition: transform 0.35s cubic-bezier(0.4,0.4,0.25,1.35);
}

.diygw-switch-box.checked {
  border-color: #04BE02;
  background-color: #04BE02;
}

.diygw-switch {
  position: absolute;
  left: -9999px;
}

.diygw-switch-box.checked:before {
  -webkit-transform: scale(0);
  transform: scale(0);
}

.diygw-switch-box.checked:after {
  -webkit-transform: translateX(20px);
  transform: translateX(20px);
}

@mixin set-radio-type($type) {
  .check-#{$type} {
    .diygw-icon-radio.checked, .diygw-icon-checkbox.checked,.diygw-switch-box.checked{
      border-color: var(--#{$type}) !important;
      background-color: var(--#{$type}) !important;
    }
  }
}

@each $type in $diygw-colors {
  @include set-radio-type($type);
}
